#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include"AXBOpenGLWidget.h"
#include"OpenGLWidgetEBO.h"
#include"OpenGLWidgetMultiObject.h"
#include"OpenGlWidgetCtl.h"
#include"OpenGlWidgetTextue.h"
#include"OpenGlWidgetTextueMouseKey.h"
#include"OpenGLWidgetLight.h"
#include<QDebug>
#include<QToolBar>
#include<QStackedWidget>
#include"QOpenGLTexture"
#include<QLabel>
#include<QLayout>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
	stackedWidget = new QStackedWidget(this);
	labeldes = new QLabel(this);
	labeldes->setText("");
	//this->layout()->addWidget(label);
	this->statusBar()->addWidget(labeldes);
	this->layout()->addWidget(stackedWidget);
	this->setCentralWidget(stackedWidget);
	//this->setCentralWidget(new OpenGLWidgetTextureMouseKey(this));
	//this->setCentralWidget(new OpenGLWidgetLight(this));
	QToolBar* mb = new QToolBar(this);
	{
		QAction* ac = new QAction("光照");
		connect(ac, &QAction::triggered, this, [=]() {
			static OpenGLWidgetLight* w = new OpenGLWidgetLight(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	{
		QAction* ac = new QAction("三角形");
		connect(ac, &QAction::triggered, this, [=]() {
			static AXBOpenGLWidget* w = new AXBOpenGLWidget(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	{
		QAction* ac = new QAction("鼠标键盘控制");
		connect(ac, &QAction::triggered, this, [=]() {
			static OpenGLWidgetTextureMouseKey* w = new OpenGLWidgetTextureMouseKey(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	{
		QAction* ac = new QAction("纹理");
		connect(ac, &QAction::triggered, this, [=]() {
			static OpenGLWidgetTest* w = new OpenGLWidgetTest(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	{
		QAction* ac = new QAction("EBO测试");
		connect(ac, &QAction::triggered, this, [=]() {
			static OpenGLWidgetEBO* w = new OpenGLWidgetEBO(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	{
		QAction* ac = new QAction("多VAO对象");
		connect(ac, &QAction::triggered, this, [=]() {
			static OpenGLWidgetMultiObject* w = new OpenGLWidgetMultiObject(this);
			stackedWidget->addWidget(w);
			stackedWidget->setCurrentWidget(w);
			labeldes->setText(w->description);
		});
		mb->addAction(ac);
	}
	this->addToolBar(mb);
}


MainWindow::~MainWindow()
{
    delete ui;
}

